Memory management is an important factor affecting system performance. A memory management module in an existing computer system is mainly responsible for allocation, recycling, swap-in, and swap-out of memory units. “Allocation” refers to selecting, by a memory management module, a suitable memory unit from an idle memory unit list and allocating the memory unit to a process when the process applies for a memory unit to the computer system. “Recycling” refers to, when a memory unit is released by a process, placing, by a memory management module, the released memory unit back to the idle memory unit list and performing appropriate defragmentation. “Swap-out” refers to, when a physical memory is insufficient, storing, by a memory management module, process data or process code that is not urgent to an external storage (a disk or the like), so that a memory unit occupied by the process data or the process code is released to be used by an urgent process or used by the computer system. “Swap-in” refers to writing, by a memory management module, swapped-out process data or code, when necessary, back to a memory unit which has already become idle.
Currently, a real-time factor is considered to some extent during “swap-out”. For example, in a case in which hardware supports reference bit (RB), a usual practice is that a computer system regularly resets reference bits of all memory units; and if a memory unit is accessed within a period, the reference bit of the memory unit is set to one. In this way, before the computer system resets the reference bit next time, if the reference bit is 1, it indicates that the memory unit was accessed in a previous period. When a memory unit is selected for swap-out, a memory unit whose reference bit is 0, that is, a memory unit not accessed in a previous period, is preferentially considered. However, considering performance overheads caused by resetting the reference bits of all memory units, a period for resetting the reference bits is relatively long, resulting in poor real-time quality. In addition, one access and 1000 accesses have the same manifestation, which cannot reflect true access frequency of a memory unit. After memory unit that are not accessed are all swapped out, that is, when all reference bits are 1, memory units to be swapped out can only be selected randomly. In this case, if the swapped-out memory units are frequently accessed, execution efficiency of the computer system is affected to some extent, and the execution efficiency of the computer system is reduced.